package com.hqyj.project.controller;


import com.hqyj.project.entity.Dept;
import com.hqyj.project.service.DeptService;
import com.hqyj.project.utils.CommonResult;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/info")
    @ResponseBody
    @RequiresRoles(value = {"admin","manager"},logical = Logical.OR)         //权限管理
    public CommonResult selectAll(Dept dept){
        return deptService.selectAll(dept);
    }

    @PostMapping("/update")
    @ResponseBody
    @RequiresRoles(value = {"admin","manager"},logical = Logical.OR)         //权限管理
    public CommonResult updateById(Dept dept){
        return deptService.updateById(dept);
    }

    @DeleteMapping("/delete/{deptId}")
    @ResponseBody
    @RequiresRoles(value = {"admin","manager"},logical = Logical.OR)         //权限管理
    public CommonResult deleteById(@PathVariable Integer deptId){
        return deptService.deleteById(deptId);
    }


    @PostMapping("/insert")
    @ResponseBody
    @RequiresRoles(value = {"admin","manager"},logical = Logical.OR)         //权限管理
    public CommonResult insertOne(Dept dept){
        return deptService.insertOne(dept);
    }

}
